package test;

import common.Util;
import org.openqa.selenium.By;

/**
 * @projectName: BlogUIAutoTest
 * @package: test
 * @className: ListPage
 * @author: Tongxinxin
 * @description: TODO
 * @date: 2025/9/4 15:19
 * @version: 1.0
 */
public class ListPage extends Util {
    /**
     * 检查博客列表页——三个模块（菜单模块、个人信息模块、博客列表模块）
     *
     * 演示——博客列表模块
     */
    public void checkListPage() throws InterruptedException {
        createDriver();
        driver.get("http://8.137.19.140:9090/blog_list.html");
        //博客标题
        String title = driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(1) > div.title")).getText();
        //博客发布时间
        String pushTime = driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(1) > div.date")).getText();
        //博客内容
        String content = driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(1) > div.desc")).getText();
        //"查看全文“按钮
        String button = driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(1) > a")).getText();

        //校验文本
        assert !title.isEmpty();
        assert !pushTime.isEmpty();
        assert !content.isEmpty();

        assert button.equals("查看全文>>");

        //点击"查看全文“按钮，检查跳转是否正确
        driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(1) > a")).click();
        Thread.sleep(500);
        String jump_title = driver.findElement(By.cssSelector("body > div.container > div.right > div > div.title")).getText();
        Thread.sleep(500);
        assert title.equals(jump_title);


//        //获取到有效的博客详情页url
//        detailUrl = driver.getCurrentUrl();
    }

}
